<template>
  <div>
    <!-- 搜索栏 -->
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="学号">
        <el-input v-model="formInline.user" placeholder="学号"></el-input>
      </el-form-item>
      <el-form-item label="专业">
        <el-select v-model="formInline.region" placeholder="专业">
          <el-option v-for="(item, index) in classed" :key="index" :value="item"
            >{{ item }}
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格区域 -->
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="姓名" width="120">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.student_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="学号" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">
            {{ scope.row.article_studentId }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="专业" width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.student_class }}</span>
        </template>
      </el-table-column>
      <el-table-column label="教师成绩" width="120">
        <template slot-scope="scope">
          <span style="margin-left: 10px">
            {{ scope.row.article_teacherscore }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="评阅教师成绩" width="150">
        <template slot-scope="scope">
          <span style="margin-left: 10px">
            {{ scope.row.look_teacherScore }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="答辩小组成绩" width="150">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.reply_score }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最终成绩" width="170">
        <template slot-scope="scope">
          <a href="javascript:;" @click="show(scope.row)">
            {{ scope.row.allScore }}
          </a>
        </template>
      </el-table-column>
      <el-table-column label="论文" width="180">
        <template slot-scope="scope">
          <a href="javascript:;" @click="download(scope.row)">
            {{ scope.row.article_name }}
          </a>
        </template>
      </el-table-column>
    </el-table>

    <!-- 成绩弹出框 -->
    <el-dialog title="提示" :visible.sync="dialogVisibles" width="40%">
      <el-descriptions class="margin-top" :column="2" border>
        <el-descriptions-item>
          <template slot="label">指导教师评分</template>
          {{ score.article_teacherscore }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">指导教师评语</template>
          {{ score.teacher_observation }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">评阅教师评分</template>
          {{ score.look_teacherScore }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">评阅教师评语</template>
          {{ score.look_teacherObservation }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label" width="40px">答辩教师评分</template>
          {{ score.reply_score }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">答辩教师评语</template>
          {{ score.reply_observation }}
        </el-descriptions-item>
      </el-descriptions>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibles = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisibles = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

    <!-- 分页区域 -->
    <el-pagination
      background
      layout="prev, pager, next"
      :page-size="queryinfo.pageSize"
      :current-page="queryinfo.current"
      :total="total"
      :hide-on-single-page="page"
    >
    </el-pagination>
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  created() {
    this.getAll_scrore();
  },
  data() {
    return {
      total: null,
      page: true,
      queryinfo: {
        pageSize: 5,
        current: 1,
      },
      formInline: {},
      tableData: [],
      score: {},
      dialogVisibles: false,
      college_name: [],
      college: "",
      classed: [],
    };
  },
  computed: {
    ...mapState(["collegeFilter", "collegeName"]),
  },
  methods: {
    ...mapMutations(["filte"]),
    getAll_scrore() {
      const info = { ...this.formInline, ...this.queryinfo };
      this.$http
        .get("http://127.0.0.1:8080/minAdmin/student_score", { params: info })
        .then((res) => {
          if (res.data.status == 0) {
            this.tableData = res.data.data.datalist;
            this.total = res.data.data.total;
          } else {
            this.tableData = [];
          }
          console.log(res);
          this.college = res.data.data.college;
          this.filte(this.college);
          this.classed = this.collegeFilter[0].collegeClass;
        })
        .catch((err) => {
          // this.$message.error(err);
        });
    },
    onSubmit() {
      this.getAll_scrore();
    },

    show(row) {
      this.dialogVisibles = true;
      this.score = row;
    },
    download(row) {
      // console.log(row);
      location.href = "http://127.0.0.1:8080/api/teacher_download?id=" + row.id;
    },
  },
};
</script>
<style lang="less" scoped>
.el-pagination {
  position: fixed;
  top: 70%;
  left: 50%;
  transform: translate(-50%, 0);
}
</style>
